mid_registrar/usrloc: fix De-REGISTER failures on cluster peers (#3845)#3883
Open
denyspozniak wants to merge 1 commit intoOpenSIPS:masterfrom
Open
mid_registrar/usrloc: fix De-REGISTER failures on cluster peers (#3845)#3883denyspozniak wants to merge 1 commit intoOpenSIPS:masterfrom
denyspozniak wants to merge 1 commit intoOpenSIPS:masterfrom
Conversation
Fixes the race in `full-sharing-cluster` mode where peers received REPL_URECORD_INSERT packets with an empty kv_storage. The serialization that 343f452 added shipped whatever was in r->kv_storage at replicate time, but mid_registrar's store_urecord_data() ran *after* ul.insert_urecord() — so peers saw an empty store and later failed to issue De-REGISTERs: ERROR:usrloc:store_deserialize: bad JSON input or oom ERROR:mid_registrar:unregister_record: 'from' key not found, skipping De-REGISTER ERROR:mid_registrar:mid_reg_aor_event: failed to unregister contact Mirror the existing ucontact pattern (ucontact_info_t.pre_replicate_cb): extend insert_urecord() with an optional pre-replication callback that the caller can use to attach record-level data between mem_insert and replicate_urecord_insert. mid_registrar wires mid_reg_store_aor_data into the throttle-AoR save path so the kv_storage is populated before the INSERT packet is built. Closes OpenSIPS#3845 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #3845
Problem
In
full-sharing-clustermode, every replicated AoR insert logs thefollowing on peer nodes, and the AoR can never be De-REGISTER'd
upstream when it expires:
ERROR:usrloc:store_deserialize: bad JSON input or oom
ERROR:mid_registrar:unregister_record: 'from' key not found, skipping De-REGISTER
ERROR:mid_registrar:mid_reg_aor_event: failed to unregister contact
Cause
Since
343f452c1,replicate_urecord_insert()shipsr->kv_storage. But inmid_registrar(save_restore_req_contacts)store_urecord_data()runs afterul.insert_urecord(), so theINSERT packet is broadcast with an empty map. Peers
cJSON_Parse("")→ NULL, and the missing keys (
from,to,callid,main_reg_uri,ct_uri,last_cseq) break De-REGISTER on expiry.Fix
Mirror the existing ucontact pattern (
pre_replicate_cb): add anoptional pre-replication callback to
insert_urecord()so the callercan fill
kv_storagebetweenmem_insert_urecord()andreplicate_urecord_insert().mid_registrarplugsmid_reg_store_aor_datainto that hook in the throttle-AoR path.All other call sites pass
NULL, NULL— no behaviour change.Verified
2-node
127.0.0.1cluster,mid_registrarmode 2 +usrlocfull-sharing-cluster. After the fix, node2'sbin_pop_strforREPL_URECORD_INSERTalready contains the full kv map, nostore_deserializeorunregister_recorderrors, and De-REGISTERreaches the main registrar on expiry.